<%@page import="org.jcms.model.Book"%>
<%@page import="org.jcms.service.BookServiceI"%>
<%@page
	import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String ISBN = request.getParameter("ISBN");
	if (ISBN == null) {
		out.print("ISBN参数错误");
		return;
	}
	ApplicationContext ac = WebApplicationContextUtils
			.getRequiredWebApplicationContext(this.getServletContext());
	BookServiceI bookServiceI = (BookServiceI) ac
			.getBean("bookServiceImpl");

	Book book = bookServiceI.findById(ISBN);
	if (book == null) {
		out.print("此书ISBN在数据库里不存在" + ISBN);
		return;
	}
%>
<script type="text/javascript">
	function ajaxsubmit() {
		if ($('#addForm').form('validate') != true)
			return;
		AjaxSubmit2("../StorehouseAddBookCount.do?bookIsbn="
				+ $("#addnumber").val() + "&addNumber="
				+ $("#addBookCount").val(),

		"ajaxLoginImg2",

		"添加书号为" + $("#addnumber").val() + "的书" + $("#addBookCount").val()
				+ "本",

		function(msg) {
			showAlert("操作成功", msg);
			$('#win').window('close');
			$("#list_data").datagrid('reload');
		},

		function(msg) {
			showAlert("操作失败", msg);

		}

		);
	}
</script>
<form id="addForm">
	<div style="text-align: center;">
		<table style="margin-top: 15px;margin:auto;">
			<tr style="height: 30px">
				<td colspan="2" style='text-align: center; font-size: 14px'>图书入库</td>
			</tr>
			<tr style="height: 30px">
				<td>ISBN：</td>
				<td><%=ISBN%><input type="hidden" id="addnumber"
					value="<%=ISBN%>" /></td>
			</tr>
			<tr style="height: 30px">
				<td>库存:</td>
				<td><%=book.getBookStock()%></td>
			</tr>
			<tr style="height: 30px">
				<td>缺书情况:</td>
				<td><%=-1 * (book.getBookStock() - book.getBookOrderNumber()) <= 0 ? "不缺"
					: -1 * (book.getBookStock() - book.getBookOrderNumber())%></td>
			</tr>

			<tr style="height: 30px">
				<td>入库数量:</td>
				<td><input type="text" id="addBookCount" name="addBookCount"
					class="easyui-validatebox"
					data-options="required:true,missingMessage:'不能为空'" />
				</td>
			</tr>
			<tr>
				<td colspan="2" valign="middle"><a href="javascript:void(0)"
					id="ajaxLoginBtn" class="easyui-linkbutton" onclick='ajaxsubmit();'>提交</a>
				</td>

			</tr>
		</table>
	</div>
</form>
<img src="../../images/loading.gif"
	style="display: none; height: 25px; width: 25px;" id="ajaxLoginImg2" />

